var gulp = require('gulp');
var less = require('gulp-less');//编译less
var bower = require('gulp-bower');//bower管理
var babel = require('gulp-babel');//编译jsx
var watch = require('gulp-watch');//监听文件变化
var del = require('del');//文件删除操作
var mainBowerFiles = require('main-bower-files');


gulp.task('del:vendor', function(cd) {
  del(['static/vendor'], cd);
});

gulp.task('bower:download', function() {
  return bower();
});

gulp.task('bower:install', ['bower:download'], function() {
  gulp.src(mainBowerFiles(), {base: 'bower_components'})
      .pipe(gulp.dest('static/vendor'));
});

gulp.task('less:CSStransform', function() {
  gulp.src('static/src/less/*')
      .pipe(less())
      .pipe(gulp.dest('static/builder/css'));
});

gulp.task('babel:JSXtransform', function() {
  gulp.src('static/src/js/*')
      .pipe(babel({
        presets: ['react']
      }))
      .pipe(gulp.dest('static/builder/js/'));
});



gulp.task('default', ['del:vendor', 'bower:install', 'less:CSStransform', 'babel:JSXtransform']);
